#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 10010;
int p[N], w[N];
int n, m;
int root(int x)
{
    if (p[x] == x || p[p[x]] == p[x]) return p[x];
    int r = root(p[x]);
    w[x] += w[p[x]];
    p[x] = r;
    return p[x];
}
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++) p[i] = i;
    for (int i = 0; i < m; i++)
    {
        int op, a, b;
        cin >> op >> a >> b;
        if (op == 1)
        {
            a = root(a), b = root(b);
            if (a != b)
            {
                p[b] = a;
                w[b] -= w[a];
            }
        }
        else
        {
            a = root(a);
            w[a] += b;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if (i == root(i)) cout << w[i] << " ";
        else cout << w[i] + w[p[i]] << " ";
    }
    return 0;
}